﻿using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls.Primitives;

namespace NavigationBarDemo.Controls.Interfaces
{
    /// <summary>
    /// 改变按钮组中选中项事件的委托类型
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public delegate void SelectionChangedHandler(object sender, RoutedEventArgs e);

    /// <summary>
    /// 按钮组接口
    /// </summary>
    /// <typeparam name="T">从ButtonBase派生的按钮类型</typeparam>
    public interface IButtonGroup<T> where T : ButtonBase
    {
        #region 属性
        /// <summary>
        /// 获取按钮个数
        /// </summary>
        int Count { get; }

        /// <summary>
        /// 获取按钮集合
        /// </summary>
        List<T> Items { get; }

        /// <summary>
        /// 获取或设置选中项的索引，如果不包含选中项返回-1
        /// </summary>
        int SelectedIndex { get; set; }

        /// <summary>
        /// 获取或设置选中的按钮对象，如果不包含选中项则返回null
        /// </summary>
        T SelectedItem { get; set; }

        /// <summary>
        /// 获取选中的按钮集合，如果不包含选中项则返回null
        /// </summary>
        List<T> SelectedItems { get; }
        #endregion

        #region 方法
        /// <summary>
        /// 添加按钮
        /// </summary>
        /// <param name="pButton">需要添加的按钮对象</param>
        void AddItem(T pButton);

        /// <summary>
        /// 移除按钮
        /// </summary>
        /// <param name="pButton">需要移除的按钮对象</param>
        void RemoveItem(T pButton);

        /// <summary>
        /// 移除按钮
        /// </summary>
        /// <param name="pIndex">按钮索引</param>
        void RemoveItem(int pIndex);

        /// <summary>
        /// 移除按钮
        /// </summary>
        /// <param name="pText">按钮上的显示或提示文字</param>
        void RemoveItem(string pText);

        /// <summary>
        /// 清空按钮
        /// </summary>
        void ClearItems();
        #endregion

        #region 事件
        /// <summary>
        /// 改变按钮组中选中项事件
        /// </summary>
        event SelectionChangedHandler SelectionChanged;

        #endregion
    }
}
